package com.sleeping.mall.common.utils.result;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 返回列表公用DTO
 * Created by ChenDong on 2018/5/14.
 */
public class ResponseList<T> implements Serializable {

    private boolean success = true;

    private String msg = "";

    private List<T> obj;

    public ResponseList(boolean success, String msg) {
        this.success = success;
        this.msg = msg;
    }

    public ResponseList(boolean success, String msg, List<T> obj) {

        this.success = success;
        this.msg = msg;
        this.obj = obj;
    }

    public ResponseList(ResponseWrapper<T> responseWrapper) {
        this.success = responseWrapper.isSuccess();
        this.msg = responseWrapper.getMsg();
        List<T> obj = new ArrayList<>();
        obj.add(responseWrapper.getObj());
        this.obj = obj;
    }

    public boolean isSuccess() {
        return success;
    }

    public ResponseList<T> setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public ResponseList<T> setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public List<T> getObj() {
        return obj;
    }

    public ResponseList<T> setObj(List<T> obj) {
        this.obj = obj;
        return this;
    }

    public ResponseList() {
    }

    public ResponseList(List<T> obj) {
        this.obj = obj;
    }
}
